package binarytree;

import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:周次煜
 * Date: 2024-04-03
 * Time：14:59
 */



public class TestMyBinaryTree {

    public static void main1(String[] args) {


        MyBinaryTree mbt=new MyBinaryTree();
        MyBinaryTree.TreeNode root=mbt.createBinaryTree();
        System.out.println("======前序遍历=======");
        mbt.FirstDisplayNo(root);
        mbt.FirstDisplay(root);
        System.out.println("\n======中序遍历=======");
        mbt.middleDisplayNo(root);

        mbt.middleDisplay(root);
        System.out.println("\n======后序遍历=======");
        mbt.lastDisplayNo(root);
        mbt.lastDisplay(root);

        System.out.println("\n======树的节点个数=====");
        System.out.println(mbt.Size(root));
        mbt.setNodeSize(root);
        System.out.println(mbt.nodeSize);
        System.out.println("\n======叶子个数=======");
        System.out.println(mbt.leafSize(root));
        mbt.setLeafSize(root);
        System.out.println(mbt.leafSize);

        System.out.println("\n=========查找节点=========");

        System.out.println(mbt.find(root, 'H').val);


        System.out.println("\n==========树的最大深度=======");

        System.out.println(mbt.treeHeight(root));


        System.out.println("=============树某深度节点数======");
        System.out.println(mbt.treeIndexlength(root, 3));

        System.out.println("=========树key深度的所有节点=========");
        System.out.println(mbt.treeIndexSize(root,2));

        System.out.println("==========层序遍历============");
        mbt.levelOrder(root,0);
        System.out.println(mbt.lists);

        System.out.println("==========判断是否是完全二叉树=======");
        System.out.println(mbt.isCompleteTree(root));



    }


    public static void main(String[] args) {
//        MyBinaryTree mbt=new MyBinaryTree();
//       MyBinaryTree.TreeNode root= mbt.createBinaryTree1("ABC##DE#G##F###");
//        mbt.FirstDisplayNo(root);

        char []arr1={'A','B','D','E','H','C','F','G'};
        char []arr2={'D','B','E','H','A','F','C','G'};
        MyBinaryTree myt=new MyBinaryTree();
       MyBinaryTree.TreeNode root1= myt.buildTree(arr1,arr2);
       myt.lastDisplay(root1);
    }



}


class Test {
    public static void main1(String[] args) {
        Stack<Integer> s=new Stack<>();


        // 先在栈顶入栈
        s.push(1);
        s.push(2);
        s.push(3);

        System.out.println("=========== 栈的大小 ======");
        System.out.println(s.size());


        System.out.println("========栈是否为空=========");
        if (s.empty()) {
            System.out.println("该栈为空！");
        } else {
            System.out.println("该栈不为空!");
        }
    }

    public static void main(String[] args) {
        MyBinaryTree myb=new MyBinaryTree();
       MyBinaryTree.TreeNode root= myb.createBinaryTree();
       MyBinaryTree.TreeNode p=new MyBinaryTree.TreeNode('G');
       MyBinaryTree.TreeNode q=new MyBinaryTree.TreeNode('H');
        System.out.println(myb.lowestCommonAncestor(root, p, q));

        System.out.println("=========创建层序遍历=========");
        System.out.println(myb.levelOrderBottom(root));
    }


}
